// Fill out your copyright notice in the Description page of Project Settings.


#include "Pickup/TUAmmoPickup.h"
#include "Component/TUHealthComponent.h"
#include "Component/TUWeaponComponent.h"
#include "TUUtils.h"
bool ATUAmmoPickup::GivePickupTo(APawn* PlayerPawn)
{
    const auto HealthComponent = TUUtils::GetTUPlayerComponent<UTUHealthComponent>(PlayerPawn);
    if (!HealthComponent || HealthComponent->IsDead()) return false;

    const auto WeaponComponent = TUUtils::GetTUPlayerComponent<UTUWeaponComponent>(PlayerPawn);
    if (!WeaponComponent) return false;

    return WeaponComponent->TryToAddAmmo(WeaponType, ClipsAmount);
}
